﻿var as='slide-in-right',at=200;// 默认动画时间
var preate={};
var _openw=null;
//打开新页面
function pclicked(obj){
    var url='';
    if(typeof obj=='object'){
         url=obj.getAttribute('url') ?obj.getAttribute('url') :'';
    }else
    {
         url=obj;
    }
    //var url=obj.getAttribute('url') ?obj.getAttribute('url') :'';
    if(_openw){return;}
    _openw=preate[url];
    if(_openw){
        if(_openw.showded){
            _openw.show('auto',at);
        }else{
            _openw.show(as,at);
            _openw.showded=true;
        }
        _openw=null;
    }else{
        var wa=plus.nativeUI.showWaiting();
        var pre='';
        arguments[1] ? pre='' :pre=JS_SITE_DOMAIN+'/app/';
        var  ref_url=plus.storage.getItem('ref_url');
        document.cookie="ref_url="+ref_url;
        _openw=plus.webview.create(pre+url,url,{scrollIndicator:'none',scalable:false},{preate:true});
        preate[url]=_openw;
        plus.storage.setItem('ref_url', url);
        _openw.addEventListener('loaded',function(){//叶面加载完成后才显示
            setTimeout(function(){//延后显示避免低端机上闪屏
                wa.close();
                _openw.show(as,at);
                _openw.showded=true;
                _openw=null;
            },500);
        },false);
        _openw.addEventListener('close',function(){//页面关闭后可再次打开
            _openw=null;
            preate[url]&&(preate[url]=null);//兼容窗口的关闭
        },false);
    }
}
var i=1
function Jump(data){
	mui.toast(data.msg);
	if (data.url && typeof(data.url)!="undefined" && data.url!=0){
		setTimeout(pclicked(data.url),2000);
	}
}
function ucopyToClip(data){
	switch ( plus.os.name ) {
	    case "Android":
	    	var Context = plus.android.importClass("android.content.Context");
    	    var main = plus.android.runtimeMainActivity();
    	    var clip = main.getSystemService(Context.CLIPBOARD_SERVICE);
    	    plus.android.invoke(clip,"setText",data);
    	    mui.toast("复制成功");
	    	break;
	    case "iOS":
	    	var UIPasteboard  = plus.ios.importClass("UIPasteboard");
	    	var generalPasteboard = UIPasteboard.generalPasteboard();
	    	// 设置/获取文本内容:
	    	generalPasteboard.setValueforPasteboardType(data, "public.utf8-plain-text");
	    	mui.toast("复制成功");
	    	break;
	    
	    default:break;
	}
}